<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">
	<ui:composition template="/templates/padraoJSF.xhtml">
		<ui:define name="barraTitulo">Cadastro de Professor</ui:define>
		<ui:define name="conteudo"> 
			<h:form id="form">
				<p:growl id="messages"/>		
				<fieldset>
					<p:tabView>
						<p:tab title="Manuten&ccedil;&atilde;o">
							<h:panelGrid columns="2" columnClasses="width150 alinhaDir" >	
									<h:outputLabel value="Matr&iacute;cula:"/>
									<h:inputText value="#{controleProfessor.pesquisaMatricula}" styleClass="textfield" size="15" />
									<h:outputLabel value="Nome:" />
									<h:inputText value="#{controleProfessor.pesquisaNome}" styleClass="textfield" size="100" />
									<h:outputLabel value="CPF: "/>
									<h:inputText value="#{controleProfessor.pesquisaCPF}" styleClass="textfield" size="15" />
									<h:column/>
							</h:panelGrid>
						</p:tab>
					</p:tabView>
				</fieldset>
				<p:commandLink action="#{controleProfessor.pesquisar}" update="lista">
					<h:graphicImage url="/images/botoes/btnPesquisar.png" styleClass="hand"  />
				</p:commandLink>
				<h:commandLink action="#{controleProfessor.incluir}" >
					<h:graphicImage url="/images/botoes/btnNovo.png" styleClass="hand" />
				</h:commandLink>
			</h:form>
			<h:form id="lista" >
				<p:dataTable value="#{controleProfessor.lista}" 
				             id="id_ListaProfessor"
				             var="professor" 
				             paginator="true" 
				             rows="10" 
				             dynamic="true" 
				             rendered="#{not empty controleProfessor.lista}" 
							 firstPageLinkLabel="Primeiro"
				             previousPageLinkLabel="Anterior"
				             nextPageLinkLabel ="Pr&oacute;ximo"
				             lastPageLinkLabel="&Uacute;ltima"
				             emptyMessage="Nenhum resgistro encontrado"
				             errorMessage="Ocorreu um erro"
    			             selection="#{controleProfessor.professor}" 
				             selectionMode="single" >
					<p:column sortBy="#{professor.matricula}" resizable="true" styleClass="width60"  >
						<f:facet name="header">
							<h:outputText value="Matr&iacute;cula" />
						</f:facet>
						<h:outputText value="#{professor.matricula}" />
					</p:column>
					<p:column sortBy="#{professor.pessoa.nome}" resizable="true">
						<f:facet name="header">
							<h:outputText value="Nome" />
						</f:facet>
						<h:outputText value="#{professor.pessoa.nome}" />
					</p:column>
					<p:column sortBy="#{professor.pessoa.CPF}" resizable="true">
						<f:facet name="header">
							<h:outputText value="CPF" />
						</f:facet>
						<h:outputText value="#{professor.pessoa.CPF}">
							<f:converter converterId="converteCPF" />
						</h:outputText>
					</p:column>
					<p:column resizable="true" styleClass="width80">
						<f:facet name="header">
							<h:outputText value="A&ccedil;&atilde;o" /> 
						</f:facet>
						<h:commandLink action="#{controleProfessor.alterar}" >  
							<p:graphicImage url="/images/marcadores/editar.png"  alt="Alterar Professor"/>  
							<f:setPropertyActionListener target="#{controleProfessor.professor}" value="#{professor}" />
						</h:commandLink>
						<p:commandLink onclick="dlg.show();">  
							<p:graphicImage url="/images/marcadores/apagar.png" alt="Excluir Professor"/>  
							<f:setPropertyActionListener target="#{controleProfessor.professor}" value="#{professor}" />
						</p:commandLink>
					</p:column>
				</p:dataTable>
			</h:form>
			<p:dialog widgetVar="dlg" header="Mensagem" width="300" fixedCenter="true" modal="true">
				<h:form >
					<h:panelGrid columns="1">
						<h:outputText value="Deseja Realmente Excluir ?"/>
						<h:column >
			            	<p:commandButton value="Sim" action="#{controleProfessor.excluir}" update=":lista" oncomplete="dlg.hide();" />  
			                <p:commandButton value="N&atilde;o" update="form" oncomplete="dlg.hide();"/>									
						</h:column>
					</h:panelGrid>
				</h:form>
			</p:dialog>
		</ui:define>
	</ui:composition>
</html>
